//
// @author				mitchell
// @description		020101.html页面的JS打包文件 注意引用顺序
// @lastmodified		$2010-7 - 15$
$(document).ready(function(){
	$(".del_x").click(function(event){
		event.preventDefault();
		$('.wm_zwj').hide(200);
	});
	
	$("#searchTextField").focus(function(){
		var _this = this;
		$(".search_qp").show(200);
		$(this).val();
		$(this).attr("placeholder",'')
		$(_this).blur(function(){
			$(".search_qp").hide();
			$(this).attr("placeholder",'请输入所在地址,或商圈,或大厦');
		});
	});
	//all_somo 查找商圈    
	$(".get_areas").click(function(event){
	    $('html,body').animate({ scrollTop:285 },500)
	});
	/*
	 * 图片墙
	 */
	$(".pic_js").mouseover(function(event){
		event.preventDefault();
		$(".wal_q,.wal_q1").hide();
		var _this = this;
		var num = $(_this).attr("num");
		var i = -3;
		var info = false;
		if(num > 12 && num <= 24){i=80;}
		if(num > 24 && num <= 36){i=160;}
		
		var val = 0;
		if(num <=6){val = (Number(num)-1)*82;}
		if(num >= 13 && num <= 24){val = (Number(num) - 13)*82;}
		if(num >= 25 && num <= 36){val = (Number(num) - 25)*82;}
		
		if(num >= 7  && num <= 12){val = (12-Number(num))*80; info = true;}
		if(num >= 19 && num <= 24 ){val = (24-Number(num))*80; info = true;}
		if(num >= 31 && num <=36){val = (36-Number(num))*80; info = true;}
		$(".wal_q,.wal_q1").css("top",i+"px");
		if(info){
			$(".wal_q1").css("right",val+"px").show(200);
		}else{
			$(".wal_q").css("left",(val-8)+"px").show(200);
		}
	});
	$(".wal_wz").mouseover(function(){
		$(".wal_q,.wal_q1").hide();
	});
	
	$(".Picture_wal").mouseleave(function(){
		if($(".wal_q,.wal_q1").is(":animated")){
			$(".wal_q,.wal_q1").stop(true,true).hide();
			return false;
		}
		$(".wal_q,.wal_q1").hide();
	});
	$(".indexMap").click(function(){
		var div = $(this).attr("type");
		$("html,body").animate({scrollTop: $(this).offset().top}, 700); 
		if(div==1){
			$(this).attr("type","2");
			$(this).html("关闭地图");
			$('#notice_click_map').show();
		}else{
			$(this).attr("type","1");
			$(this).html("从地图上选取");
			$('html,body').animate({ scrollTop:0 },500);
			$('.marker-xuan').hide();
		}
		$(".index_map").toggle(800);
		mapoption();
	});
	
	$(".get_area").click(function(event){
		event.preventDefault();
		var s = $(document).scrollTop();
	    $('html,body').animate({ scrollTop:531 },1000);
	});
	
	var somoname = js_context.somoname;
	$(".somo_input").blur(function(event){
		var value = $.trim($(this).val());
		if(!value){
			if(somoname){
				$(this).val(somoname);
				return false;
			}
			$(this).val("请输入您所在的大厦");
		}
	});
	
	var input_data = $.trim($("#searchTextField").val());
	$(".iadd").keyup(function(evnet){
		if(input_data != $.trim($("#searchTextField").val())){
			$(this).attr('geocodeinput','0');
			var input_data = $.trim($("#searchTextField").val());
		}
	})
	
	//search input
	$(".iadd").click(function(event){
		var data = $.trim($("#searchTextField").val());
		if(data=="" || data == js_context.search_input_notice){
			alert("请您先输入地址");
			event.preventDefault();
		}else{
			if($("#searchTextField").attr('geocodeinput') == 0){
				getLatLng(data);
				return false;
			}else{
				var lat = $(".lat").val();
				var lng = $(".lng").val();
				if(!lat ||!lng){
					alert('该地址不合法');
					return false;
				}
			}
		}
		
	});
	
	//index search
	$("#searchTextField").keypress( function(e) {
		var key = window.event ? e.keyCode : e.which;
		if(key.toString() == "13"){
			var lat = $(".lat").val();
			var lng = $(".lng").val();
			if(!lat ||!lng){
				return false;
			}
		}
	});

	function getLatLng(address){
		var geocoder = new google.maps.Geocoder();  
		if (geocoder) {  
			geocoder.geocode({'address':'北京 '+address,'region':'cn'}, function(results, status) {  
			    if (status == google.maps.GeocoderStatus.OK) {  
			         if (results[0]) {  
			        	 // alert(results[0].formatted_address);  
			             address = results[0].formatted_address;
			             latlng = results[0].geometry.location;
			     		 if(latlng.lat()> 40.567618 || latlng.lat()< 39.818331 || latlng.lng()<116.282644 || latlng.lng()>116.507298){
			     			alert("您查询的地址太过模糊，或者可能已经超出北京了，请重新输入更详细的地址");
			     			return false;
			     		 }
			     		 $(".lat").val(latlng.lat());
			     		 $(".lng").val(latlng.lng());
			     		var lat = $(".lat").val();
						var lng = $(".lng").val();
						if(!lat ||!lng){
							alert('该地址不合法');
							return false;
						}else{
							$(this).attr('geocodeinput','1');
				     		$("#form_search").trigger("submit");
						}
			     		 
			     		 return false;
			         }  
			    } else {
			    	alert("["+address+"]无法查询到，请您输入更详细的地址");
			    }
			});  
		}
	}
	//getLatLng('大半截胡同');
	
	//address_index area
	$(".add-area").mouseover(function(event){
		var _this = this;
		$(".area_list").show();
	});
	$(".add-area").mouseleave(function(event){
		$(".area_list").hide();
	});
	$(".areaname").click(function(event){
		event.preventDefault();
		var area = $(this).html();
		var aid = $(this).attr('aid');
		$(".add-area").find("span").html(area);
		$(".add-area").find("span").attr('aid',aid);
		$(".area_aid").val(aid);
		$(".area_list").hide();
	});
	//index hotarea
	$(".hot_area").click(function(event){
		event.preventDefault();
		if($(".shuangyu").is(":animated")){
			return false;
		}
		$(".shuangyu").hide();
		$(".h_yc").attr("type","h_xs");
		var _this = this;
		var num = $(_this).attr("num");
		$(".arealist,.hot_area").css("color","");
		$(_this).css("color","red");
		$(".area_"+num).css("color","red");
		$(".h_xs").hide();
		$(".hot-ta11, .h_yc").show(800);
	});
	$(".hotArea").click(function(event){
		event.preventDefault();
		var div = $(this).attr("type");
		$(this).hide();
		$(".shuangyu").hide(800);
		$("."+div).show();
		if(div == 'sy'){
			$(".h_xs").show();
			$(".shuangyu,.h_yc").hide(800);
			$(".h_yc").attr("type","h_xs");
			$(".arealist,.hot_area").css("color","");
			return false;
		}
		$(".hot-ta11").toggle(800);
	});
	
	$(".index_shuangyu").click(function(event){
		event.preventDefault();
		var _this = this;
		if($(".hot-ta11").is(":animated")){
			return false;
		}
		$(".shuangyushu_loading").show();
		var type = $(_this).attr('type');
		if(type == 'y'){
			$(".arealist,.hot_area").css("color","");
			$(".hot-ta11,.h_xs").hide();
			$(".shuangyu,.h_yc").show(800);
			$(".h_yc").attr("type","sy");
			$(".shuangyushu_loading").hide();
			return false;
		}
		var url = js_context.base_url+"ajax/account/shuangyushu";
		$.get(url,{},function(result){
			$(".shuangyushu_loading").hide();
			$(_this).attr('type','y');
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var html = result.message;
			$(".shuangyu-guide").html(html).show();
			$(".arealist,.hot_area").css("color","");
			$(".hot-ta11,.h_xs").hide();
			$(".shuangyu,.h_yc").show(800);
			$(".h_yc").attr("type","sy");
		},"json");
		
		
	});

	//index sys
	/*
	$(".pic_3").click(function(event){
		event.preventDefault();
		$('html,body').animate({ scrollTop:373 },1000)
		$(".arealist,.hot_area").css("color","");
		$(".hot-ta11,.h_xs").hide();
		$(".shuangyu,.h_yc").show(800);
		$(".h_yc").attr("type","sy");
	});
	*/
	//index banner
	/*
	;(function($){
		$.fn.iFadeSlide = function(iSet){
		var	iSet = $.extend({high:'ah',interval:3000,leaveTime:150,fadeOutTime:400,fadeInTime:400},iSet);
			    var imgField = $(iSet.field || '#slide>img');
			    var icoField = $(iSet.ico || '#ico');
			    var curIndex = 0;
			    var slideInterval = iSet.interval || 3000;
			    var hoverTime = iSet.leaveTime || 150;
			    var fadeOutTime = iSet.fadeOutTime || 400;
			    var fadeInTime = iSet.fadeInTime || 400;
			    var icos=null, fastHoverFun = null, autoSlideFun = null, hasIcoHighCls = null, changeFun = null,max=null;;
			    var icoHtml = '';
			    max=imgField.size();
			    //按图片传入对应的按钮
			    imgField.each(function(i){
			        icoHtml += '<a href="javascript:void(0)" class="toc">'+'</a>';
			    });
			    icoField.append(icoHtml);
			    //淡入淡出函数
			    changeFun = function(n){
			        imgField.filter(':visible').fadeOut(fadeOutTime, function(){
			            imgField.eq(n).fadeIn(fadeInTime)
			            icos.eq(n).addClass(iSet.high).siblings().removeClass(iSet.high);
			        });
			    }
			    icos = icoField.find('a');
			    //为第一个按键初始化高亮
			    icos.first().addClass(iSet.high);
			    //按钮鼠标划入划出事件
			    icos.hover(function(){
		        clearInterval(autoSlideFun);
			        curIndex = icos.index(this);
			        hasIcoHighName = $(this).hasClass(iSet.high);
			        //setTimeout避免用户快速(无意识性划过)划过时触发事件
			        fastHoverFun = setTimeout(function(){
			            //鼠标划入当前图片按钮时不闪烁
			            if (!hasIcoHighName) {
			                changeFun(curIndex);
			            }
			        }, hoverTime);
			    }, function(){
			        clearTimeout(fastHoverFun);
			        //自动切换
			        autoSlideFun = setInterval(function(){
			            curIndex++;
			            changeFun(curIndex);
			            if (curIndex ==max ) {
			                changeFun(0);
			                curIndex = 0;
			            }
			        }, slideInterval)
			    }).eq(0).trigger('mouseleave');
			 
			    //当鼠标划入图片区域时停止切换
			    imgField.hover(function(){
			        curIndex = imgField.index(this);
			        clearInterval(autoSlideFun);
			    }, function(){
			        icos.eq(curIndex).trigger('mouseleave');
			    });
			}})(jQuery);   
	$(function(){
	        $('div#slide').iFadeSlide({
	                field: $('div#slide img'),
	                ico: $('div.ico'),
	                high:'ah',
	                interval:6000,
	                leaveTime:200,
	                fadeInTime:1000,
	                fadeOutTime:200
	        });

	});
	*/
	//index banner
	;(function($){
		$.fn.iFadeSlide = function(iSet){
		var	iSet = $.extend({high:'curimg',interval:3000,leaveTime:150,fadeOutTime:400,fadeInTime:400},iSet);
			    var imgField = $(iSet.field || '#slide>img');
			    var icoField = $(iSet.ico || '#ico');
			    var curIndex = 0;
			    var slideInterval = iSet.interval || 3000;
			    var hoverTime = iSet.leaveTime || 150;
			    var fadeOutTime = iSet.fadeOutTime || 400;
			    var fadeInTime = iSet.fadeInTime || 400;
			    var icos=null, fastHoverFun = null, autoSlideFun = null, hasIcoHighCls = null, changeFun = null,max=null;;
			    var icoHtml = '';
			    max=imgField.size();
			    //按图片传入对应的按钮
			    imgField.each(function(i){
			        icoHtml += '<a href="javascript:void(0)" class="toc">'+'</a>';
			    });
			    icoField.append(icoHtml);
			    //淡入淡出函数
			    changeFun = function(n){
			        imgField.filter(':visible').fadeOut(fadeOutTime, function(){
			            imgField.eq(n).fadeIn(fadeInTime)
			            icos.eq(n).addClass(iSet.high).siblings().removeClass(iSet.high);
			        });
			    }
			    icos = icoField.find('a');
			    //为第一个按键初始化高亮
			    icos.first().addClass(iSet.high);
			    //按钮鼠标划入划出事件
			    icos.hover(function(){
		        clearInterval(autoSlideFun);
			        curIndex = icos.index(this);
			        hasIcoHighName = $(this).hasClass(iSet.high);
			        //setTimeout避免用户快速(无意识性划过)划过时触发事件
			        fastHoverFun = setTimeout(function(){
			            //鼠标划入当前图片按钮时不闪烁
			            if (!hasIcoHighName) {
			                changeFun(curIndex);
			            }
			        }, hoverTime);
			    }, function(){
			        clearTimeout(fastHoverFun);
			        //自动切换
			        autoSlideFun = setInterval(function(){
			            curIndex++;
			            changeFun(curIndex);
			            if (curIndex ==max ) {
			                changeFun(0);
			                curIndex = 0;
			            }
			        }, slideInterval)
			    }).eq(0).trigger('mouseleave');
			 
			    //当鼠标划入图片区域时停止切换
			    imgField.hover(function(){
			        curIndex = imgField.index(this);
			        clearInterval(autoSlideFun);
			    }, function(){
			        icos.eq(curIndex).trigger('mouseleave');
			    });
			}})(jQuery);   
	$(function(){
	        $('div#slide').iFadeSlide({
	                field: $('div#slide img'),
	                ico: $('div.ico'),
	                high:'curimg',
	                interval:6000,
	                leaveTime:200,
	                fadeInTime:1000,
	                fadeOutTime:200
	        });

	});
	
	$(".gg_gb").click(function(event){
		event.preventDefault();
		$(".banner_h").hide(800);
	});
	
	//get somo tree
	var index_aid = js_context.aid;
	$(".area a").click(function(event){
		event.preventDefault();
		$(".area_List").css("color","");
		$(this).css("color","red");
		$(".somoArr,.somoArr_t,.trad_arr").hide();
		$(".area_loading").show();
		var _this = this;
		var url = $(_this).attr('href');
		var aid = $(_this).attr('aid');
		if(aid==$(".somo_"+aid).attr("aid")){
			$(".somo_"+aid).show();
			$(".area_"+aid).show();
			$(".area_loading").hide();
			return false;
		}
		$.get(url,{'aid':aid},function(result){
			$(".area_loading").hide();
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var datainfo = result.viewDiv;
			if(!datainfo){
				alert('查询失败');
				return false;
			}
			var html ='<div class="somo_'+aid+' somoArr" aid="'+aid+'">'+datainfo+'</div>';
			$("#le-retri").append(html).show();
			
			var data = result.message;
			if(!data){
				alert('暂无商圈');
				return false;
			}
			var html = '<div class="area_'+aid+' trad_arr" aid="'+aid+'">';
			for(var i=0;i<data.length;i++){
				html += '<a class="';
				if(data[i].hot>0){
					html += 'ab ';
				}
				html+='trad trad_'+data[i].taid+'" taid="'+data[i].taid+'" href="'+js_context.base_url+'ajax/search/search_somo_tree">'+data[i].name+'</a>';
			}
			html += '<div style="clear:both;"></div></div>';
			$(".lett-a2c1").append(html).show();
			//商圈搜索大厦
			$(".area_"+aid+" a").click(function(event){
				event.preventDefault();
				$(".somoArr_t,.somoArr").hide();
				$(".trad_loading").show();
				var taid = $(this).attr("taid");
				var url = $(this).attr("href");
				if(taid==$(".somo_t_"+taid).attr("taid")){
					$(".somo_t_"+taid).show();
					$(".trad_loading").hide();
					//$(".area_"+aid).show();
					return false;
				}
				$.get(url,{'taid':taid},function(result){
					$(".trad_loading").hide();
					if(result.success == false){
						alert('通讯失败');
						return false;
					}
					var datainfo = result.viewDiv;
					if(!datainfo){
						alert('查询失败');
						return false;
					}
					var html ='<div class="somo_t_'+taid+' somoArr_t" taid="'+taid+'">'+datainfo+'</div>';
					$("#le-retri").append(html).show();
				},"json");
			});
			
		},"json");
		
	});
	
	$(".area_"+index_aid+" a").click(function(event){
		event.preventDefault();
		$(".somoArr_t,.somoArr").hide();
		$(".trad_loading").show();
		var taid = $(this).attr("taid");
		var url = $(this).attr("href");
		if(taid==$(".somo_t_"+taid).attr("taid")){
			$(".somo_t_"+taid).show();
			$(".trad_loading").hide();
			return false;
		}
		$.get(url,{'taid':taid},function(result){
			$(".trad_loading").hide();
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var datainfo = result.viewDiv;
			if(!datainfo){
				alert('查询失败');
				return false;
			}
			var html ='<div class="somo_t_'+taid+' somoArr_t" taid="'+taid+'">'+datainfo+'</div>';
			$("#le-retri").append(html).show();
		},"json");
	});

	/*
	var index_aid = js_context.aid;
	$(".area a").click(function(event){
		event.preventDefault();
		$(".trad_arr").hide();
		$(".area_loading").show();
		var _this = this;
		var url = $(_this).attr('url');
		var aid = $(_this).attr('aid');
		if(aid==$(".area_"+aid).attr("aid")){
			$(".area_"+aid).show();
			$(".area_loading").hide();
			return false;
		}
		$.get(url,{'aid':aid},function(result){
			$(".area_loading").hide();
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var datainfo = result.message;
			if(!datainfo){
				alert('查询失败');
				return false;
			}
			var html = '<div class="area_'+aid+' trad_arr" aid="'+aid+'">';
			for(var i=0;i<datainfo.length;i++){
				html += '<a href="javascript:void(0)">'+datainfo[i].name+'</a>';
			}
			html += '<div style="clear:both;"></div></div>';
			$(".lett-a2c1").append(html).show();
		},"json");
	});	
	*/
/*
	var BannerSlideshow = new Class({
		options: {
		showControls: false,
		showDuration: 10000,
		showTOC: true,
		tocWidth: 450,
		tocClass: 'toc',
		tocActiveClass: 'toc-active'
		},
		Implements: [Options,Events],
		initialize: function(container,elements,options) {
		//settings
		this.container = $(container);
		this.elements = $$(elements);
		this.currentIndex = 0;
		this.interval = '';
		if(this.options.showTOC) this.toc = [];
		//assign
		this.elements.each(function(el,i){
		if(this.options.showTOC) {
		this.toc.push(new Element('a',{
		text: "",
		href: '#',
		'class': this.options.tocClass + '' + (i == 0 ? ' ' + this.options.tocActiveClass : ''),
		events: {
		click: function(e) {
		if(e) e.stop();
		this.stop();
		this.show(i);
		}.bind(this)
		},
		styles: {
		left: ((i * 30) + (this.options.tocWidth))
		}
		}).inject(this.container));
		}
		if(i > 0) el.set('opacity',0);
		},this);
		//next,previous links
		if(this.options.showControls) {
		this.createControls();
		}
		//events
		this.container.addEvents({
		mouseenter: function() { this.stop(); }.bind(this),
		mouseleave: function() { this.start(); }.bind(this)
		});
		},
		show: function(to) {
		this.elements[this.currentIndex].fade('out');
		if(this.options.showTOC) this.toc[this.currentIndex].removeClass(this.options.tocActiveClass);
		this.elements[this.currentIndex = ($defined(to) ? to : (this.currentIndex < this.elements.length - 1 ? this.currentIndex+1 : 0))].fade('in');
		if(this.options.showTOC) this.toc[this.currentIndex].addClass(this.options.tocActiveClass);
		},
		start: function() {
		this.interval = this.show.bind(this).periodical(this.options.showDuration);
		},
		stop: function() {
		$clear(this.interval);
		},
		//"private"
		createControls: function() {
		var next = new Element('a',{
		href: '#',
		id: 'next',
		text: '>>',
		events: {
		click: function(e) {
		if(e) e.stop();
		this.stop();
		this.show();
		}.bind(this)
		}
		}).inject(this.container);
		var previous = new Element('a',{
		href: '#',
		id: 'previous',
		text: '<<',
		events: {
		click: function(e) {
		if(e) e.stop();
		this.stop();
		this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
		}.bind(this)
		}
		}).inject(this.container);
		}
		});

	
	
	
  window.addEvent('domready',function() {
	     var slideshow = new BannerSlideshow('slideshow-container','#slideshow-container img', {'showDuration': 10000});
	     slideshow.start();
  });
  */
	//index get somo old

	$("#somo a").click(function(event){
		$(".area_trading").hide();
		$(".area_loading").show();
		event.preventDefault();
		var _this = this;
		
		var url = $(this).attr('href');
		var aid = $(this).attr('aid');
		
		$('.a0').not('.a1_'+aid).removeAttr('class');
		$(this).attr('class','a0 a1_'+aid);
		if($(this).attr('loading') == 'Y'){
			$(".area_loading").hide();
			$(".area_" + aid).show();
			return false;
		}
		$.get(url,{'aid':aid},function(result){
			$(".area_loading").hide();
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var datainfo = result.info;
			if(!datainfo){
				alert('查询失败');
				return false;
			}
			var url = js_context.base_url+"search?somoid=";
			var html = '<div class="area_'+aid+' area_trading">';
			for(var i=0;i<datainfo.length;i++){
				html += '<a href="'+url+datainfo[i].somoid+'">'+datainfo[i].name+'</a>';
			}
			html += '</div>';
			$(_this).attr('loading','Y');
			$("#data").append(html).show();
		},"json");
	});	
	$(".consultation").click(function(event){
		event.preventDefault();
		$("#content").focus();
	});
	
	$("#somo a").click(function(event){
		$(".area_trading").hide();
		$(".area_loading").show();
		event.preventDefault();
		var _this = this;
		
		var url = $(this).attr('href');
		var aid = $(this).attr('aid');
		
		$('.a0').not('.a1_'+aid).removeAttr('class');
		$(this).attr('class','a0 a1_'+aid);
		if($(this).attr('loading') == 'Y'){
			$(".area_loading").hide();
			$(".area_" + aid).show();
			return false;
		}
		$.get(url,{'aid':aid},function(result){
			$(".area_loading").hide();
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var datainfo = result.info;
			if(!datainfo){
				alert('查询失败');
				return false;
			}
			var url = js_context.base_url+"search?somoid=";
			var html = '<div class="area_'+aid+' area_trading">';
			for(var i=0;i<datainfo.length;i++){
				html += '<a href="'+url+datainfo[i].somoid+'">'+datainfo[i].name+'</a>';
			}
			html += '</div>';
			$(_this).attr('loading','Y');
			$("#data").append(html).show();
		},"json");
	});	
	
	$('.a1').click(function(){
		var _this = this;
		var aid = $(this).attr('aid');
		var url = js_context.base_url+"ajax/search/indextrading";
		$(this).parent().parent().parent().find(".trad_loading").show();
		if($(".somoaid_new_"+aid).attr('aid')==aid){
			$(_this).parent().parent().parent().find(".trad_loading").hide();
			$(".somoaid_new_"+aid).show();
			$(".a1_"+aid).hide();
			return false;
		}
		$.get(url,{'aid':aid},function(result){
			$(_this).parent().parent().parent().find(".trad_loading").hide();
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var data= result.message;
			if(!data){
				alert('加载失败');
				return false;
			}
			var html = "";
			for(var i=0;i<data.length;i++){
				if(i==0){
					html += '<span><img src="'+js_context.base_url+'res/images/xiaob.gif" /></span><a href="'+js_context.base_url+'search?taid='+data[i].taid+'" title="'+data[i].name+'">'+data[i].name.substring(0,4)+'</a>';
				}
				if(i%4!=0){
					html += '<span><img src="'+js_context.base_url+'res/images/xiaob.gif" /></span>';
				}
					html += '<a href="'+js_context.base_url+'search?taid='+data[i].taid+'" title="'+data[i].name+'">'+data[i].name.substring(0,4)+'</a>';
				
			}
			html += '<a href="javascript:void(0)" class="a1 a2_'+aid+'"><img src="'+js_context.base_url+'res/images/shouqiq.gif" /></a>';
			$(".a1_"+aid).hide();
			$(".somoaid_new_"+aid).append(html).attr('aid',aid).show();
			
			$(".a2_"+aid).click(function(){
				$(".somoaid_new_"+aid).hide();
				$(".a1_"+aid).show();
			});
		
		},"json");
	});
	
	//banner hide
	$('#banner_pic').click(function(event){
		event.preventDefault();
		$('.intros').hide();
	});
	//点评 排名
	$('#order a').mouseover(function(event){
		var key = $(this).attr('key');
		if($("#ul" + key).css('display') !='none' )
			return false;
		
		if($("#ul"+key).html() != ''){
			$(this).attr('class','hover');
			$('#order a').not(this).attr('class','tab_list');
			$('.hot > ul').hide();
			$("#ul"+key).show();
			return false;
		}
		$(this).attr('class','hover');
		$('#order a').not(this).attr('class','tab_list');
		
		$('.hot > ul').hide();
		$('.tab_loading').show();

		$.get(js_context.base_url+"ajax/search/indexTab", { "key" : key }, function(result){
			$('.tab_loading').hide();
			if(result.success == false){
				alert('通讯失败');
				$("#ul0").show();
				return false;
			}
			var data = result.message;
			if(!data){
				alert('查询失败');
				$("#ul0").show();
				return false;
			}
			var html = '';
			for(var i=0;i<data.length;i++){
				html += '<li><a href="'+js_context.base_url+'store/'+data[i].sid+'"><font>';
				html += i+1;
				html += '.</font>';
				html += data[i].store;
				html += '</a><span>'+Number(result.order[i].num)+'</span></li>';
			}
			$('.hot > ul').hide();
			$("#ul"+key).html(html).show();
		},"json");
		
	});
	
	//login
/*	$("#email").click(function(event){
		var value = $.trim($(this).val());
		if(value=='也可以用昵称或手机号码登录'){
			$(this).val("");
		}
	});
	$("#email").blur(function(event){
		var value = $.trim($(this).val());
		if(!value){
			$(this).val("也可以用昵称或手机号码登录");
		}
	});*/
	
	$("#login1").click(function(event){
		event.preventDefault();
		var url = js_context.base_url + "user/login";
		var email = $("#email").val();
		var password = $("#psd").val();
		$.post(url,{ "mail" : email,"password" :password }, function(r){
			//var obj = $.parseJSON(r);
			if (r.success) {
				window.location.href = js_context.base_url;
			}else{
				$("html,body").scrollTop(0);
				$("#wrong").html(r.msg).show();
				return false;
			}

		},"json");
	});
	
	//index search old 右部
	$(".search > ul > a").click(function(event){
		event.preventDefault();
		$('#tab_s').removeAttr('id');
		$(this).attr('id','tab_s');
		$("#search_index").attr('typeid',$(this).attr('type'));
		$("#form_url").attr('action',$(this).attr('form_url'));
	});
	
	//$(".keyword").autocomplete(js_context.base_url+'ajax/search/indexsearch');
	
	$('#username').blur(function(){
		var username = $.trim($("#username").val());
		if(username == ""){
			$('.username').show();
			$('.img3').hide();
			//$("#username").focus();
			$('.user_submit input').attr("disabled", "true");
			return false;
		}else{
			$('.username').hide();
			$('.img3').show();
			$('.user_submit input').attr("disabled", "");
		}
	});
	
	$('#tel').blur(function(){
		var tel = $.trim($("#tel").val());
		if(tel == ""){
			$('.tel').show();
			$('.telimg').hide();
			$('.user_submit input').attr("disabled", "true");
			return false;
		}else{
			$('.tel').hide();
			$('.telimg').show();
			$('.user_submit input').attr("disabled", "");
		}
	});
	
	//del ustatid
	/*
	function AutoScroll(obj){
		$(obj).find(".hdsc:first").animate({
			marginTop:"-25px"
		},500,function(){
			$(this).css({marginTop:"0px"}).find(".hdsc:first").appebdTo(this);
		});
	}
	setInterval(AutoScroll(".hds"),1000);
	*/
	$(".hdsc").mouseover(function(event){
		var _this = this;
		var ustatid = $(_this).attr("ustatid");
		$(".del_"+ustatid).show();
	});
	$(".hdsc").mouseleave(function(event){
		var _this = this;
		var ustatid = $(_this).attr("ustatid");
		$(".del_"+ustatid).hide();
	});
	$(".sx1").click(function(event){
		event.preventDefault();
		var _this = this;
		var ustatid = $(_this).attr("ustatid");
		var url = $(_this).attr("url");
		$('.loading_'+ustatid).show();
		$('.store_'+ustatid).fadeOut();
		$.get(url,{ "ustatid" : ustatid}, function(result){
			$('.loading_'+ustatid).hide();
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var data = result.message;
			if(!data){
				alert('删除失败');
				return false;
			}
			if(data=="notlogin"){
				alert('请先登录');
				return false;
			}
			if(data=="error"){
				alert('删除失败');
				return false;
			}
			$('.store_'+ustatid).hide();
		},"json");
	});
	
	/*var map;
	var position_marker = false;
	function creat_map(latitude,longitude){
		//默认中心位置
		latlng = new google.maps.LatLng(39.9579201,116.3876719);
		var myOptions = {
			    zoom: 12,
			    center: latlng,
			    mapTypeId: 'roadmap',
			    mapTypeControl:false,
			    streetViewControl:false,
			    navigationControl:true,
			    navigationControlOptions: {
			        style: google.maps.NavigationControlStyle.ZOOM_PAN,
			        position: google.maps.ControlPosition.TOP_LEFT
			    },
			    scaleControl: true 
		}; 
		map = new google.maps.Map(document.getElementById("search_map"), myOptions);
		var homeControlDiv = document.createElement('DIV');
		homeControlDiv.setAttribute("class", "map_storeinfo");
		var child_dom = document.getElementById("m_storeinfo");
		homeControlDiv.appendChild(child_dom);
		homeControlDiv.index = 1;
		map.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);
 		return map;
	}
	
	if(js_context.index){
	   var input = document.getElementById('searchTextField');
	   var defaultBounds = new google.maps.LatLngBounds(
			  new google.maps.LatLng(40.067618, 116.282644),
			  new google.maps.LatLng(39.818331, 116.507298)
		);var options = {
			  bounds: defaultBounds
			};
		
			autocomplete = new google.maps.places.Autocomplete(input, options);
			google.maps.event.addListener(autocomplete, 'place_changed', function() {
				  var place = autocomplete.getPlace();
				  $(".lat").val(place.geometry.location.lat());
				  $(".lng").val(place.geometry.location.lng());
				});
	}

	function mapoption(){
		creat_map();
		google.maps.event.addListener(map, 'click', function(event) {
			if(position_marker) position_marker.setVisible(false);
			
			placeMarker(event.latLng);
			$("#m_storeinfo").html('加载中......');
			$(".s_pic").hide();
			$(".s_load").show();
			google.maps.event.addListener(position_marker, 'drag', function() {
				//$("#latlnginfo").html(position_marker.getPosition().lat()+','+position_marker.getPosition().lng());
			});
				  
			google.maps.event.addListener(position_marker, 'dragend', function() {
				$("#m_storeinfo").html('加载中......');
				$(".s_load").show();
				$(".s_pic").hide();
				geocodePosition(position_marker.getPosition());
			});
		});
	}
	//from positon get address
	function geocodePosition(pos) {
		var geocoder = new google.maps.Geocoder();
		geocoder.geocode({
			latLng: pos
		}, function(responses) {
			if (responses && responses.length > 0) {
				var result_address = responses[0].formatted_address.split(" 邮政编码");
				$("#searchTextField").val(result_address[0]);
				$('html,body').animate({ scrollTop:260 },500);
				$(".s_pic").show();
			} else {
				alert("获取不到地址。请重新选取您所在的地址~");				
			}
			$(".s_load").hide();
			$("#m_storeinfo").html('');
			$('#notice_click_map').hide();
			$('#notice_drag_map').show();
		});
	}
	function placeMarker(location) {
		map.setZoom(16);
		map.panTo(location);
		position_marker = new google.maps.Marker({
			position: location,
			draggable: true,
			map: map
		});
		
		$(".lat").val(position_marker.getPosition().lat());
		$(".lng").val(position_marker.getPosition().lng());
		geocodePosition(position_marker.getPosition());
		return position_marker;
	}*/
	
	$("#yonghe").click(function(event){
		event.preventDefault();
		var url =js_context.base_url+"ajax/account/banner";
		var ip = $(this).attr("ip");
		$.get(url,{}, function(result){
			if(result.success == false){
				alert('通讯失败');
				return false;
			}
			var data = result.message;
			$('.yonghe').slideUp(800);
		 },"json");
	});
	/*
	function SetCookie_b(ip){
		var Then = new Date() 
		Then.setTime(Then.getTime() + 30*24*60*60*1000 ) //60秒
		document.cookie = "user_ip="+ip+";expires="+ Then.toGMTString() ;
	}
	
	function GetCookie_b(ip){ 
		var arrCookie = document.cookie.split(";");
		var cookie_ip = false;
		for(var i=0;i<arrCookie.length;i++){ 
	         var arr=arrCookie[i].split("="); 
	         if('user_ip' == $.trim(arr[0])){
	        	 cookie_ip=arr[1];
	        	 continue;
	         }
		}
		if(ip == cookie_ip){
			return ip;
		}else{
			return false;
		}
		
	}
	
	var yonghe = GetCookie_b('user_'+js_context.redirect_ip);
	if(!yonghe){
		$('.yonghe').show();
		SetCookie_b('user_'+js_context.redirect_ip,'1');
	}else{
		$('.yonghe').hide();
	}
	*/
	function SetCookie(ip,city){
		var Then = new Date() 
		Then.setTime(Then.getTime() + 30*24*60*60*1000 ) //60秒
		document.cookie = "user_redirect_ip="+ip+";expires="+ Then.toGMTString() ;
		document.cookie = "redirect_city="+city+";expires="+ Then.toGMTString();
	}

	function GetCookie(ip){ 
		var arrCookie = document.cookie.split(";");
		
		var cookie_ip = false;
		var cookie_city = false;
		for(var i=0;i<arrCookie.length;i++){ 
	         var arr=arrCookie[i].split("="); 
	         
	         if('user_redirect_ip' == $.trim(arr[0])){
	        	 cookie_ip=arr[1];
	        	 continue;
	         }
	         if('redirect_city' == $.trim(arr[0])){ 
	        	 cookie_city=arr[1];
	         }
		}

		if(ip == cookie_ip){
			return cookie_city;
		}else{
			return false;
		}
	}

	if(js_context.redirect){
		var status = GetCookie('redirect_'+js_context.redirect_ip);
		if(!status){
			if(confirm("检测到您当前所在IP属于上海市。您需要我们为您切换到上海分站么？")){
				SetCookie('redirect_'+js_context.redirect_ip,'shanghai');
				window.location.href = js_context.redirect;
			}else{
				SetCookie('redirect_'+js_context.redirect_ip,'beijing');
				return false;
			}
		}else{
			if(status == 'shanghai'){
				window.location.href = js_context.redirect;
			}
		}
	}
	 
	$(".qq_dcl1").click(function(event){
		event.preventDefault();
		$('#divFloatToolsView').animate({width: 'show', opacity: 'show'}, 'normal',function(){ 
				$('#divFloatToolsView').show(); 
			});
		$('#aFloatTools_Show').attr('style','display:none');
		$('#aFloatTools_Hide').attr('style','display:block');
	});
	
	$(".qq_dcl2").click(function(event){
		event.preventDefault();
		//$(".qq_dcl1").show();
		$('#divFloatToolsView').animate({width: 'hide', opacity: 'hide'}, 'normal',function(){ 
			$('#divFloatToolsView').hide(); 
		});
		$('#aFloatTools_Show').attr('style','display:block');
		$('#aFloatTools_Hide').attr('style','display:none');
	});
	
	$(".qq_qehb2").mouseover(function(){
		$(".qq_jg").show();
	});
	
	$(".qq_qehb2").mouseleave(function(){
		$(".qq_jg").hide();
	});

	function kf_setCookie(name, value, exp, path, domain)
	{
		var nv = name + "=" + escape(value) + ";";

		var d = null;
		if(typeof(exp) == "object")
		{
			d = exp;
		}
		else if(typeof(exp) == "number")
		{
			d = new Date();
			d = new Date(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes() + exp, d.getSeconds(), d.getMilliseconds());
		}
		
		if(d)
		{
			nv += "expires=" + d.toGMTString() + ";";
		}
		
		if(!path)
		{
			nv += "path=/;";
		}
		else if(typeof(path) == "string" && path != "")
		{
			nv += "path=" + path + ";";
		}

		if(!domain && typeof(VS_COOKIEDM) != "undefined")
		{
			domain = VS_COOKIEDM;
		}
		
		if(typeof(domain) == "string" && domain != "")
		{
			nv += "domain=" + domain + ";";
		}

		document.cookie = nv;
	}

		
	
});
